package cn.wolfcode.shop.service;

import cn.wolfcode.shop.domain.SkuProperty;
import cn.wolfcode.shop.mapper.SkuPropertyMapper;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service@Transactional
public class SkuPropertyServiceImpl implements ISkuPropertyService {
    @Autowired
    private SkuPropertyMapper skuPropertyMapper;

    @Override
    public List<SkuProperty> listByCatalogId(Long catalogId) {
        return skuPropertyMapper.listByCatalogId(catalogId);
    }

    @Override
    public void saveOrUpdate(SkuProperty skuProperty) {
        if (skuProperty.getId() != null) {
            skuPropertyMapper.updateByPrimaryKey(skuProperty);
        } else {
            skuPropertyMapper.insert(skuProperty);
        }
    }

    @Override
    public void delete(Long id) {
        skuPropertyMapper.deleteByPrimaryKey(id);
    }

    @Override
    public SkuProperty get(Long id) {
        return skuPropertyMapper.selectByPrimaryKey(id);
    }
}
